package com.yx.robot.component;

import org.greenrobot.eventbus.EventBus;import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class Event<T> {

    public static final int MESSAGE_TYPE_ALL = 0;  //注册
    public static final int MESSAGE_TYPE_REGISTER = 1;  //注册
    public static final int MESSAGE_TYPE_GET_AUTH_CODE = 2;  //获取验证码
    public static final int MESSAGE_TYPE_CHECK_AUTH_CODE = 9;    //校验验证码
    public static final int MESSAGE_TYPE_LOGIN = 3;     //登录
    public static final int MESSAGE_TYPE_LOGOUT = 4;    //退出
    public static final int MESSAGE_TYPE_RESETPASSWORD = 5; //修改密码 重置密码
    public static final int MESSAGE_TYPE_CONFIGNETWORK = 6;
    public static final int MESSAGE_TYPE_INIT_CONFIGNETWORK = 10;
    public static final int MESSAGE_TYPE_CONFIGNETWORK_PROGRESS = 35;
    public static final int MESSAGE_TYPE_GET_DEVICE_LIST = 7;   //获取设备列表
    public static final int MESSAGE_TYPE_GET_ACCOUNT_INFO = 8;   //获取账号信息
    public static final int MESSAGE_TYPE_QUERY_ALARM = 12;      //查询预约
    public static final int MESSAGE_TYPE_QUERY_DISTURB = 13;      //查询勿扰
    public static final int MESSAGE_TYPE_ONLINE_STATE = 15;
    public static final int MESSAGE_TYPE_DOWNLOAD_HEADPICTRUE = 16; //下载头像
    public static final int MESSAGE_TYPE_SAVE_HEADPICTURE_CACHE = 161; //用户设置修改头像后 缓存到本地
    public static final int MESSAGE_TYPE_QUERY_SHARE_USER = 998;        //查询分享的用户列表
    public static final int MESSAGE_TYPE_REMOVE_SHARE_USER = 997;        //移除某个分享用户
    public static final int MESSAGE_TYPE_SHARE_DEVICE = 999;        //分享设备
    public static final int MESSAGE_TYPE_RENAME_DEVICE = 120;       //修改设备名
    public static final int MESSAGE_TYPE_DEVICE_INFO_UPDATE = 121;       //设备信息变化回调
    public static final int MESSAGE_TYPE_GET_MESSAGE_LIST = 18;     //获取消息列表
    public static final int MESSAGE_TYPE_DELETE_EQUIPMENT = 22;      //删除设备
    public static final int MESSAGE_TYPE_RESTORE_FACTORY = 17;      //恢复出厂设备
    public static final int MESSAGE_TYPE_CHECK_NEW_VERSION = 19;    //检查固件的新版本
    public static final int MESSAGE_TYPE_CHECK_UPGRADE_STATE = 37;    //固件更新状态
    public static final int MESSAGE_TYPE_UPGRADE = 20;
    public static final int MESSAGE_TYPE_UPGRADE_PROGRESS = 21;
    public static final int MESSAGE_TYPE_UPLOAD_HEADPICTRUE = 26;   //上传头像
    public static final int MESSAGE_TYPE_DELETE_MESSAGE_LIST = 27;  //删除消息列表
    public static final int MESSAGE_TYPE_HAS_NEW_MESSAGE = 28;      //查询有无新信息
    public static final int MESSAGE_TYPE_GET_CLEAN_RECORD = 29;         //获取清扫记录
    public static final int MESSAGE_TYPE_GET_CLEAN_RECORD_DETAIL = 72;         //获取清扫记录
    public static final int MESSAGE_TYPE_DELETE_CLEAN_RECORD = 30;  //删除清扫记录
    public static final int MESSAGE_TYPE_SET_NICKNAME = 31;         //设置昵称
    public static final int MESSAGE_TYPE_GET_MULTI_MAP = 32;         //获取多地图
    public static final int MESSAGE_TYPE_SAVE_MAP_SUCCESS = 33;         //保存地图
    public static final int MESSAGE_TYPE_SAVE_MAP_FAIL = 303;         //保存地图失败
    public static final int MESSAGE_TYPE_SWITCH_MAP = 34;         //切换地图
    public static final int MESSAGE_TYPE_SESSION_TIMEOUT = 36;         //登录过期
    public static final int MESSAGE_TYPE_GET_PATH_DATA = 38;       //获取路径点
    public static final int MESSAGE_TYPE_CANCEL_ACCOUNT = 39;
    public static final int MESSAGE_TYPE_MERGE_AREA_SUCCESS = 40;
    public static final int MESSAGE_TYPE_MERGE_AREA_FAIL = 41;
    public static final int MESSAGE_TYPE_REFRESH_ROOM_TAG = 42;
    public static final int MESSAGE_TYPE_ACCOUNT_BINDING = 43;
    public static final int MESSAGE_TYPE_GET_MAPDATA_SUCCESS = 44;
    public static final int MESSAGE_TYPE_RENAME_AREA_SUCCESS = 45;
    public static final int MESSAGE_TYPE_RENAME_AREA_FAIL = 46;
    public static final int MESSAGE_TYPE_SAVE_CUSTOM_SUCCESS = 47;
    public static final int MESSAGE_TYPE_CLEAR_CUSTOM_FAIL = 48;
    public static final int MESSAGE_TYPE_SAVE_CUSTOM_FAIL = 49;
    public static final int MESSAGE_TYPE_CLEAR_CUSTOM_SUCCESS = 50;
    public static final int MESSAGE_TYPE_GET_MAP_LIST = 51;
    public static final int MESSAGE_TYPE_RESET_MAP_SUCCESS = 53;
    public static final int MESSAGE_TYPE_VOICE_LIST_SUCCESS = 54;//语音列表
    public static final int MESSAGE_TYPE_DIVIDE_AREA_SUCCESS = 55;
    public static final int MESSAGE_TYPE_DIVIDE_AREA_FAIL = 56;
    public static final int MESSAGE_TYPE_TWO_ROOM_CAN_NOT_REACH = 57;//两个房间不相邻
    public static final int MESSAGE_TYPE_DELETE_MAP_SUCCESS = 58;
    public static final int MESSAGE_TYPE_SET_MAP_SUCCESS = 59; //使用地图
    public static final int MESSAGE_TYPE_SET_MAP_FAIL = 509; //使用地图失败
    public static final int MESSAGE_TYPE_CLEAR_MULTI_MAP = 60;         //清空地图
    public static final int MESSAGE_TYPE_RENAME_MULTI_MAP = 61;         //重命名多地图
    public static final int MESSAGE_TYPE_RENAME_MULTI_MAP_FAIL = 62;         //重命名多地图
    //    public static final int MESSAGE_TYPE_DISTURB_SWITCH_CHANGE = 64;
    public static final int MESSAGE_TYPE_DELETE_MULTI_MAP_SUCCESS = 63;         //删除多地图
    public static final int MESSAGE_TYPE_DELETE_MULTI_MAP_FAIL = 603;         //删除多地图
    public static final int MESSAGE_TYPE_VOICE_STATUS_PROGRESS = 65;//语音设置进度
    public static final int MESSAGE_TYPE_GET_SON_MESSAGE_LIST = 61;
    public static final int MESSAGE_TYPE_SET_AREA_SUCCESS = 66;//设置区域成功
    public static final int MESSAGE_TYPE_SET_AREA_FAIL = 67;//设置区域失败
    public static final int MESSAGE_TYPE_DUST_COLLECTION = 68;//集尘状态
    public static final int MESSAGE_TYPE_DUST_COLLECTION_NUM = 69;//集尘次数
    public static final int MESSAGE_TYPE_DELETE_ROBOT = 70;
    public static final int MESSAGE_TYPE_ALARM_CHANGED = 71;
    public static final int MESSAGE_TYPE_BASE_STATION_VERSION = 72;//基站软件版本
    public static final int MESSAGE_TYPE_DRY_STATE = 73;//基站软件版本
    public static final int MESSAGE_TYPE_REQUEST_MAP_AND_PATH = 74;//获取地图
    public static final int MESSAGE_TYPE_REQUEST_APP_UPDATE = 75;//APP 更新
    public static final int MESSAGE_TYPE_CONSUMPTION_UPDATE = 76;//耗材更新
    public static final int MESSAGE_TYPE_CLEAN_AREA_DURATION_FREQUENCY = 77;//清扫总时长，面积，次数
    public static final int MESSAGE_TYPE_CLEAN_AREA_DURATION = 78;//实时清扫时长，面积

    public static final int MESSAGE_TYPE_TANK_DUSTBOX_STATUS = 79;//水箱状态 尘盒状态
    public static final int MESSAGE_TYPE_CLEAN_MOP = 80;//清洗拖布
    public static final int MESSAGE_TYPE_NETWORK_STATUS = 81;//监听网络
    public static final int MESSAGE_TYPE_WATER_STATUS = 82;//水量
    public static final int MESSAGE_TYPE_SUCTION_STATUS = 83;//吸力
    public static final int MESSAGE_TYPE_FREQUENC_STATUS = 84;//回洗频率
    public static final int MESSAGE_TYPE_AUTO_BOOST_STATUS = 85;//地毯增压
    public static final int MESSAGE_TYPE_FAULT_STATUS = 86;//故障
    public static final int MESSAGE_TYPE_FEEDBACK_LIST = 87;//意见反馈列表
    public static final int MESSAGE_TYPE_FEEDBACK_DETAILS_LIST = 88;//意见反馈会话详情列表
    public static final int MESSAGE_TYPE_ADD_FEEDBACK_MSG = 89;//添加意见反馈
    public static final int MESSAGE_TYPE_AUTO_UPGRADE_SWITCH_STATE = 90;//获取固件自动升级开关
    public static final int MESSAGE_TYPE_SET_AUTO_UPGRADE_SWITCH_STATE = 91;//设置固件自动升级开关

    public static final int MESSAGE_TYPE_TUYA_BLUETOOTH_SCAN = 92;//涂鸦蓝牙扫描设备
    public static final int MESSAGE_TYPE_TMALL_BLUETOOTH_SCAN = 93;//天猫蓝牙扫描设备
    public static final int MESSAGE_TYPE_DETECT_ACCESS_TOKEN = 94;//天猫检测AccessToken
    public static final int MESSAGE_TYPE_AUTHORIZED_LOGIN = 95;//天猫授权登录
    public static final int MESSAGE_TYPE_AUTHORIZED_LOGIN_VERIFICATION_CODE = 96;//天猫手机号授权登录获取验证码
    public static final int MESSAGE_TYPE_AUTHORIZED_LOGIN_USER_LIST = 97;//天猫手机号授权登录用户列表
    public static final int MESSAGE_TYPE_PHONE_NUMBER_AUTHORIZED_LOGIN = 98;//天猫通过手机号生成精灵账号进行登录
    public static final int MESSAGE_TYPE_ACCESS_TOKEN_AUTHENTIATION = 99;//天猫AccessToken鉴权
    public static final int MESSAGE_TYPE_TAOBAO_AUTH_LOGIN = 100;//天猫 淘宝账号授权登录
    public static final int MESSAGE_TYPE_DEVICE_ID = 101;//天猫 设备id
    public static final int MESSAGE_TYPE_GET_AUTHCODE = 102;//天猫 获取authcode
    public static final int MESSAGE_TYPE_GET_ROBOT_INFO = 103;//天猫 获取扫地机信息
    public static final int MESSAGE_TYPE_GET_USER_DEVICE_LIST = 104;//天猫 获取用户设备列表（deviceid列表）
    public static final int MESSAGE_TYPE_GENIE_AUTH_LOGIN = 105;//天猫精灵类型账号登录
    public static final int MESSAGE_TYPE_UNBIND_USER = 106;//天猫精灵类型账号解除绑定
    public static final int MESSAGE_TYPE_GET_ALIGENIE_USER_INFO = 107;//天猫精灵 获取三方绑定的精灵账号信息
    public static final int MESSAGE_TYPE_REQUEST_APP_UPDATE_ABOUT = 108;//APP 关于页面检测更新
    public static final int MESSAGE_TYPE_UNBIND_DEVICE = 109;//天猫精灵 设备解除绑定
    public static final int MESSAGE_TYPE_GET_DEVICE_BASIC_INFO = 110;//天猫精灵 获取基站设备固件信息
    public static final int MESSAGE_TYPE_GET_QE_CONFIG_TOKEN = 111;//涂鸦二维码配网获取token
    public static final int MESSAGE_TYPE_GET_QE_BITMAP = 112;//涂鸦配网二维码
    public static final int MESSAGE_TYPE_CAMERASETTING = 113;//摄像头设置 AI 家居 实时

    public static final int MSG_ROBOT_MAP = 1001;
    public static final int MSG_ROBOT_PATH = 1002;
    public static final int MSG_ROBOT_AREA = 1003;
    public static final int MSG_ROBOT_STATE = 1004;
    public static final int MSG_ROBOT_INFO = 1005;
    public static final int MSG_ROBOT_SETTINGS = 1006;
    public static final int MSG_ROBOT_CONSUMPTION = 1007;
    public static final int MSG_ROBOT_CLEANSTATISTICS = 1008;
    public static final int MSG_ROBOT_ROOM = 1009;

    public static final int MEG_ROBOT_BASESTATION = 1113;
    public static final int MEG_ROBOT_BASESTATION_LIGHT = 1114;
    public static final int MEG_ROBOT_BASESTATION_AIRCLEAN = 1115;
    public static final int MEG_ROBOT_BASESTATION_STATE = 1116;

    public static final int MSG_MAIN_GUIDE = 1111;
    public static final int MSG_BASE_STATION_GUIDE = 1112;

    public static final int MSG_ROBOT_STATE_LOW_POWER = 1010;
    public static final int MSG_ROBOT_STATE_HEALTH_POWER = 1011;
    public static final int MSG_ROBOT_STATE_POWER = 1012;

    //扫地机摄像头相关消息
    public static final int MSG_INIT_VIDEO = 1200;
    public static final int MSG_START_PLAY_VIDEO = 1201;
    public static final int MSG_STOP_PLAY_VIDEO = 1202;
    public static final int MSG_START_RECORD_VIDEO = 1203;
    public static final int MSG_STOP_RECORD_VIDEO = 1204;
    public static final int MSG_START_RECORD_AUDIO = 1205;
    public static final int MSG_STOP_RECORD_AUDIO = 1206;
    public static final int MSG_SET_CLARITY = 1207;
    public static final int MSG_GET_CLARITY = 1208;
    public static final int MSG_SCREENSHOT = 1209;
    public static final int MSG_DESTROY_VIDEO = 1210;

    public static final int MESSAGE_TYPE_GET_MUSIC_LIST = 1014;//获取类目下的专辑列表、根据选品池ID查询选品池内容
    public static final int MESSAGE_TYPE_GET_ALBUM_DETAIL = 1015;//按照特定的id获取专辑信息
    public static final int MESSAGE_TYPE_GET_ALBUM_LIST_DETAIL = 1016;//获取音乐音频专辑里面的内容列表
    public static final int MESSAGE_TYPE_CREATE_MUSIC_LIST = 1017;//创建播放列表并播放指定的内容
    public static final int MESSAGE_TYPE_PLAY_AND_PAUSE = 1018;//播放暂停控制
    public static final int MESSAGE_TYPE_PLAY_MODE_CONTROL = 1019;//播放模式切换
    public static final int MESSAGE_TYPE_DEVICE_VOLUME_CONTROL = 1020;//设备音量等属性值控制
    public static final int MESSAGE_TYPE_PROGRESS_CONTROL = 1021;//进度控制
    public static final int MESSAGE_TYPE_PREVIOUS_AND_NEXT_CONTROL = 1022;// 对创建的播放列表中的内容进行上下一首控制
    public static final int MESSAGE_TYPE_GET_CURRENT_PLAYING_LIST = 1023;// 获取当前播放列表
    public static final int MESSAGE_TYPE_GET_CURRENT_PLAYING_ITEM_REPEAT = 1029;//反复获取当前歌曲
    public static final int MESSAGE_TYPE_GET_CURRENT_PLAYING_ITEM = 1024;// 获取当前播放项
    public static final int MESSAGE_TYPE_REFRESH_ALBUM_COVER_ICON = 1025;// 刷新封面图片
    public static final int MESSAGE_TYPE_MUSIC_PLAY_SWITCH = 1026;//
    public static final int MESSAGE_TYPE_GET_DEVICE_STATUS = 1027;// 获取天猫精灵在线状态
    public static final int MESSAGE_TYPE_GET_DEVICE_STATUS_DETAIL = 1028;// 获取天猫精灵设备详情
    public static final int MESSAGE_TYPE_GET_DEVICE_STATUS_DETAIL_REPEAT = 1030;//反复获取设备详情状态
    public static final int MESSAGE_TYPE_GET_REFRESH_PROGRESS = 1031;//反复刷新进度条
    public static final int MESSAGE_TYPE_GET_DEVICE_STATUS_INFO = 1032;//反复设备状态（online/offline）
    public static final int MESSAGE_TYPE_INDEX_PLAY_MUSIC = 1033;//播放音乐列表指定项
    public static final int MESSAGE_TYPE_SEARCH_CONTENT = 1034;//按照特定的搜索条件搜索
    public static final int MESSAGE_TYPE_ADD_AND_REMOVE_FAVORITE_CONTENT = 1035;//收藏或取消收藏
    public static final int MESSAGE_TYPE_LIST_PLAY_HISTORY = 1036;//获取历史播放接口
    public static final int MESSAGE_TYPE_GET_CONTENT = 1037;//按照特定的id获取内容信息
    public static final int MSG_ROBOT_MULTI_MAP = 1038;//多楼层地图开关
    public static final int MESSAGE_TYPE_GET_WEATHER = 1039;//获取天气接口
    public static final int MESSAGE_TYPE_DRYING_TIME = 1040;//烘干时间
    public static final int MESSAGE_TYPE_CLEAN_MOP_FREQUENCY = 1041;//清洗拖布次数
    public static final int MESSAGE_TYPE_DRY_SWITCH = 1042;//自动烘干开关
    public static final int MESSAGE_TYPE_CHILD_LOCK = 1043;//童锁childLock
    public static final int MESSAGE_TYPE_UNIT_AREA = 1044;//单位面积
    public static final int MSG_ROBOT_FURNITURE = 1045;
    public static final int MSG_ROBOT_OBJECT = 1046;
    public static final int MESSAGE_TYPE_RESET_ROOM_FAIL = 1047;
    public static final int MESSAGE_TYPE_RESET_ROOM_SUCCESS = 1048;

    public static final int MESSAGE_TYPE_RESET_GRAPHIC_PASSWORD = 1049;//密码错误恢复初始状态


    private int type;
    private boolean result;
    private T content;
    private Object extra;

    private Event(Builder<T> builder) {
        setType(builder.type);
        setResult(builder.result);
        setContent(builder.content);
        setExtra(builder.extra);
    }

    public static <T> Builder<T> newBuilder() {
        return new Builder<T>();
    }

    public T getContent() {
        return content;
    }

    public void setContent(T content) {
        this.content = content;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public boolean isResult() {
        return result;
    }

    public void setResult(boolean result) {
        this.result = result;
    }

    public Object getExtra() {
        return extra;
    }

    public void setExtra(Object extra) {
        this.extra = extra;
    }

    @Override
    public String toString() {
        return "Event{" +
                "type=" + type +
                ", result=" + result +
                ", content=" + content +
                ", extra=" + extra +
                '}';
    }

    public static final class Builder<T> {
        private int type;
        private boolean result = true;    //默认为true
        private T content;
        private Object extra;

        private Builder() {
        }

        public Builder<T> type(int type) {
            this.type = type;
            return this;
        }

        public Builder<T> result(boolean result) {
            this.result = result;
            return this;
        }

        public Builder<T> content(T content) {
            this.content = content;
            return this;
        }

        public Builder<T> extra(Object extra) {
            this.extra = extra;
            return this;
        }


        public void send() {
            Event<T> event = new Event<T>(this);
            EventBus.getDefault().post(event);
        }
    }
}
